package com.tx.test.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class RegisterServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2778960772106064467L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		String username = req.getParameter("username");
		String password = req.getParameter("password");
		String gender = req.getParameter("gender");
		String mobile = req.getParameter("mobile");
		String email = req.getParameter("email");
		
		if(!"".equals(username) && !"".equals(password) && !"".equals(gender) && !"".equals(mobile) && !"".equals(email)){
			req.setAttribute("username", username);
			req.setAttribute("password", password);
			req.setAttribute("gender", gender);
			req.setAttribute("mobile", mobile);
			req.setAttribute("email", email);
			req.getRequestDispatcher("/register_success.jsp").forward(req, resp);
		} else {
			resp.sendRedirect("/TestMvc/register_failed.jsp");
		}
	}
	
	

}
